package ONLINE_EXAM;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class test1 {
    /**
     * 统计字符串
     * 最终的集合用于统计 hashmap
     * 没读入一行
     * 判断 录入 0 2 46 位
     * @param args
     */
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //List<String> list = new ArrayList<>();
        String str ;
        Map<Character,Integer> map = new HashMap<>();
        while ((str = br.readLine())!= null){
            char team1 = str.charAt(0);
            int score1 = str.charAt(4)-48;
            char team2 = str.charAt(2);
            int score2 = str.charAt(6)-48;
            if (score1 > score2){
                map.put(team1,map.getOrDefault(team1,0)+3);
                map.put(team2,map.getOrDefault(team2,0)+0);
            }else if (score1 == score2){
                map.put(team1,map.getOrDefault(team1,0)+1);
                map.put(team2,map.getOrDefault(team2,0)+1);
            }else {
                map.put(team1,map.getOrDefault(team1,0)+0);
                map.put(team2,map.getOrDefault(team2,0)+3);
            }

        }

        List<Map.Entry<Character,Integer>> list =new ArrayList<>(map.entrySet()) ;
        Collections.sort(list, new Comparator<Map.Entry<Character, Integer>>() {
            @Override
            public int compare(Map.Entry<Character, Integer> o1, Map.Entry<Character, Integer> o2) {
                return o2.getValue().compareTo(o1.getValue());
            }
        });
        StringBuilder sb = new StringBuilder();
        for (Map.Entry entry:map.entrySet()){
            sb.append(entry.getKey()+" "+entry.getValue()+",");

        }
        sb.deleteCharAt(sb.length()-1);
        System.out.println(sb.toString());



    }
}
